<template>
  <div class="foot">
    <div
      v-for="item in arr"
      :key="item.id"
      :class="{ active: item.isActive }"
      @click="add(item.id)"
    >
      {{ item.text }}
    </div>
  </div>
</template>
<script>
export default {
  data () {
    return {
      arr: [
        { id: 1, text: '首页', className: 'HomePage', isActive: false },
        { id: 2, text: '分类', className: 'ClassBox', isActive: false },
        { id: 3, text: '其他', className: 'OtherBox', isActive: false },
        { id: 4, text: '我的', className: 'MyBox', isActive: false }
      ]
    }
  },
  created () {
  },
  computed: {
  },
  methods: {
    add (id) {
      this.arr.forEach(item => {
        if (item.id === id) {
          item.isActive = true
          this.$emit('msg', item.text)
        } else {
          item.isActive = false
        }
      })
    }
  }
}
</script>
<style lang='less'  scoped>
.foot {
  display: flex;
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 50px;
}
.foot div {
  flex: 1;
  line-height: 50px;
  text-align: center;
  border: solid 1px gray;
}
.active {
  background-color: red;
}
</style>
